﻿package mortal.game.view.wardrobe
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import baseEngine.modifiers.*;
    import com.gengine.core.frame.*;
    import com.greensock.layout.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import flash.geom.*;
    import frEngine.effectEditTool.temple.*;
    import frEngine.pools.*;
    import frEngine.primitives.object2d.*;
    import frEngine.render.layer.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.component.rotate3dModelSprite.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.window3d.*;
    import mortal.game.model.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.model.data.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.player.weapon.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.scene3D.player.type.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.pageSelect.*;
    import mortal.game.view.mount.data.*;
    import mortal.game.view.palyer.data.*;
    import mortal.game.view.wardrobe.data.*;
    import mortal.game.view.wardrobe.util.*;
    import mortal.game.view.wardrobe.view.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class WardrobeWin extends BaseWindow
    {
        private var _bg:GImageBitmap;
        private var _categoryList:GTileList;
        private var _fashionInfoList:GTileList;
        private var _pageSelecter:PageSelecter;
        private var _boxIsActive:GRadioButton;
        private var _boxForever:GRadioButton;
        private var _boxTimeLimit:GRadioButton;
        private var _boxExpired:GRadioButton;
        private var _rotate3d:Rotate3dModelSprite;
        private var _rect3d:Rect3DObject;
        private var _img2d:Img2D;
        private var _scale9gridImg2d:Scale9GridImg2DEx;
        private var _bodyPlayer:ActionPlayer;
        private var _roleModelPlayer:UserModelPlayer;
        private var _weaponPlayer:WeaponPlayer;
        private var _weaponEffectPlayer:EffectPlayer;
        private var _frameTimer:FrameTimer;
        private var _mountHangEffect:EffectPlayer;
        private var _equipArr:Array;
        private var _isInitModel:Boolean;
        private var _turnNum:Number = 0;
        public static var currSelWardrobe:int = 0;
        public static var currSelFashionType:int = 1;
        public static var currSelFashionData:ItemData;
        private static var _instance:WardrobeWin;

        public function WardrobeWin(param1:ILayer = null)
        {
            this._equipArr = [];
            super(param1);
            setSize(909 - 4, 546 - 7);
            title = Language.getString(41398);
            this.layer = LayerManager.windowLayer3D;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.gImageBitmap(ImagesConst.WardrobeBg_Mount, 0, 0, null, this.onBgLoadCompl);
            this.pushUIToDisposeVec(UIFactory.bg(10 - 2, 38 - 2, 136, 501, this));
            this._categoryList = UIFactory.tileList(17, 42, 140, 506, this);
            this._categoryList.columnWidth = 125;
            this._categoryList.rowHeight = 99;
            this._categoryList.horizontalGap = 0;
            this._categoryList.verticalGap = 0;
            this._categoryList.setStyle("cellRenderer", WardrobeCategoryCellRenderer);
            this._categoryList.configEventListener(Event.CHANGE, this.onTabBarChangeHandler);
            this.pushUIToDisposeVec(UIFactory.bg(476 - 2, 38 - 2, (425 + 1), 501, this));
            this._fashionInfoList = UIFactory.tileList(482 - 4, 44 - 4, 428, 438, this);
            this._fashionInfoList.columnWidth = 139;
            this._fashionInfoList.rowHeight = 140;
            this._fashionInfoList.horizontalGap = 0;
            this._fashionInfoList.verticalGap = 0;
            this._fashionInfoList.setStyle("cellRenderer", WardrobeInfoCellRenderer);
            var _loc_1:* = GlobalStyle.textFormatBai;
            _loc_1.align = AlignMode.CENTER;
            this._pageSelecter = UIFactory.pageSelecter(620 - 2, 470, this, PageSelecter.CompleteMode);
            this._pageSelecter.setbgStlye(ImagesConst.InputBg, _loc_1);
            this._pageSelecter.pageTextBoxSize = 50;
            this._pageSelecter.maxPage = 1;
            this._pageSelecter.configEventListener(Event.CHANGE, this.onPageChange);
            this.pushUIToDisposeVec(UIFactory.bg(477, 497 + 2, 423, 2, this, ImagesConst.SplitLine));
            this._boxIsActive = UIFactory.radioButton(Language.getString(41399), 548 - 12, 511 - 3, 66, 20, this);
            this._boxForever = UIFactory.radioButton(Language.getString(41400), 634 - 12, 511 - 3, 66, 20, this);
            this._boxTimeLimit = UIFactory.radioButton(Language.getString(41401), 715 - 12, 511 - 3, 66, 20, this);
            this._boxExpired = UIFactory.radioButton(Language.getString(41402), 791 - 12, 511 - 3, 66, 20, this);
            this._boxIsActive.groupName = "suit";
            this._boxForever.groupName = "suit";
            this._boxTimeLimit.groupName = "suit";
            this._boxExpired.groupName = "suit";
            this._boxIsActive.configEventListener(MouseEvent.CLICK, this.radioBtnChange);
            this._boxForever.configEventListener(MouseEvent.CLICK, this.radioBtnChange);
            this._boxTimeLimit.configEventListener(MouseEvent.CLICK, this.radioBtnChange);
            this._boxExpired.configEventListener(MouseEvent.CLICK, this.radioBtnChange);
            this._rotate3d = UIFactory.getUICompoment(Rotate3dModelSprite, 148 + 4 - 2, 37 + 2, this.contentTopOf3DSprite);
            this._rotate3d.setSize(323, 500);
            this.initCategoryList();
            this.initRadioList();
            this.addListeners();
            return;
        }// end function

        private function addListeners() : void
        {
            Dispatcher.addEventListener(EventName.WardrobeSelFashion, this.onSelFashionShowShape);
            NetDispatcher.addCmdListener(ServerCommand.FashionClothEquipUpdate, this.onFashionEquipUpdate);
            NetDispatcher.addCmdListener(ServerCommand.FashionWingEquipUpdate, this.onFashionEquipUpdate);
            NetDispatcher.addCmdListener(ServerCommand.FashionWeaponEquipUpdate, this.onFashionEquipUpdate);
            NetDispatcher.addCmdListener(ServerCommand.UpdateMountEquip, this.onMountEquipUpdate);
            NetDispatcher.addCmdListener(ServerCommand.UpdatePetEquip, this.onPetEquipUpdate);
            return;
        }// end function

        private function removeListeners() : void
        {
            Dispatcher.removeEventListener(EventName.WardrobeSelFashion, this.onSelFashionShowShape);
            NetDispatcher.removeCmdListener(ServerCommand.FashionClothEquipUpdate, this.onFashionEquipUpdate);
            NetDispatcher.removeCmdListener(ServerCommand.FashionWingEquipUpdate, this.onFashionEquipUpdate);
            NetDispatcher.removeCmdListener(ServerCommand.FashionWeaponEquipUpdate, this.onFashionEquipUpdate);
            NetDispatcher.removeCmdListener(ServerCommand.UpdateMountEquip, this.onMountEquipUpdate);
            NetDispatcher.removeCmdListener(ServerCommand.UpdatePetEquip, this.onPetEquipUpdate);
            return;
        }// end function

        private function initCategoryList() : void
        {
            var _loc_1:* = new DataProvider();
            _loc_1.addItem(EAdvanceComponentType._EAdvanceComponentTypeMount);
            _loc_1.addItem(EAdvanceComponentType._EAdvanceComponentTypePet);
            _loc_1.addItem(EAdvanceComponentType._EAdvanceComponentTypeWing);
            _loc_1.addItem(EAdvanceComponentType._EAdvanceComponentTypeClothes);
            _loc_1.addItem(EAdvanceComponentType._EAdvanceComponentTypeWeapon);
            this._categoryList.dataProvider = _loc_1;
            this._categoryList.drawNow();
            this._categoryList.selectedIndex = 0;
            this.onTabBarChangeHandler();
            return;
        }// end function

        private function initRadioList() : void
        {
            this._boxIsActive.selected = true;
            this.radioBtnChange();
            return;
        }// end function

        private function initInfoList() : void
        {
            var _loc_4:ItemData = null;
            var _loc_1:* = new DataProvider();
            var _loc_2:Array = [];
            var _loc_3:int = 0;
            while (_loc_3 < 9)
            {
                
                _loc_4 = new ItemData(100050302);
                _loc_2.push(_loc_4);
                _loc_3++;
            }
            _loc_1.addItems(_loc_2);
            this._fashionInfoList.dataProvider = _loc_1;
            this._fashionInfoList.drawNow();
            return;
        }// end function

        public function openWardrobePanel(param1:int) : void
        {
            var _loc_2:int = 0;
            switch(param1)
            {
                case EAdvanceComponentType._EAdvanceComponentTypeMount:
                {
                    _loc_2 = 0;
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypePet:
                {
                    _loc_2 = 1;
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypeWing:
                {
                    _loc_2 = 2;
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypeClothes:
                {
                    _loc_2 = 3;
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypeWeapon:
                {
                    _loc_2 = 4;
                    break;
                }
                default:
                {
                    break;
                }
            }
            this._categoryList.selectedIndex = _loc_2;
            this.onTabBarChangeHandler();
            return;
        }// end function

        private function onTabBarChangeHandler(event:Event = null) : void
        {
            var _loc_2:String = null;
            switch(this._categoryList.selectedIndex)
            {
                case 0:
                {
                    WardrobeWin.currSelWardrobe = EAdvanceComponentType._EAdvanceComponentTypeMount;
                    _loc_2 = ImagesConst.WardrobeBg_Mount;
                    break;
                }
                case 1:
                {
                    WardrobeWin.currSelWardrobe = EAdvanceComponentType._EAdvanceComponentTypePet;
                    _loc_2 = ImagesConst.WardrobeBg_Mount;
                    break;
                }
                case 2:
                {
                    WardrobeWin.currSelWardrobe = EAdvanceComponentType._EAdvanceComponentTypeWing;
                    _loc_2 = ImagesConst.WardrobeBg_Cloth;
                    break;
                }
                case 3:
                {
                    WardrobeWin.currSelWardrobe = EAdvanceComponentType._EAdvanceComponentTypeClothes;
                    _loc_2 = ImagesConst.WardrobeBg_Cloth;
                    break;
                }
                case 4:
                {
                    WardrobeWin.currSelWardrobe = EAdvanceComponentType._EAdvanceComponentTypeWeapon;
                    _loc_2 = ImagesConst.WardrobeBg_Artifact;
                    break;
                }
                default:
                {
                    break;
                }
            }
            this.clear();
            this.clear3D();
            this._bg.imgUrl = _loc_2;
            var _loc_3:* = Cache.instance.wardrobe.getFashionsByType(WardrobeWin.currSelWardrobe, WardrobeWin.currSelFashionType);
            this.updateFashionInfo(_loc_3);
            Dispatcher.dispatchEvent(new DataEvent(EventName.WardrobeSelDefaultFashion));
            return;
        }// end function

        private function radioBtnChange(event:MouseEvent = null) : void
        {
            var _loc_2:int = 0;
            var _loc_3:Array = null;
            if (this._boxIsActive.selected)
            {
                _loc_2 = WardrobeFashionType.Type_Active;
            }
            if (this._boxForever.selected)
            {
                _loc_2 = WardrobeFashionType.Type_Permanent;
            }
            if (this._boxTimeLimit.selected)
            {
                _loc_2 = WardrobeFashionType.Type_Time;
            }
            if (this._boxExpired.selected)
            {
                _loc_2 = WardrobeFashionType.Type_Expired;
            }
            if (WardrobeWin.currSelFashionType != _loc_2)
            {
                WardrobeWin.currSelFashionType = _loc_2;
                _loc_3 = Cache.instance.wardrobe.getFashionsByType(WardrobeWin.currSelWardrobe, WardrobeWin.currSelFashionType);
                this.updateFashionInfo(_loc_3);
                WardrobeWin.currSelFashionData = null;
                Dispatcher.dispatchEvent(new DataEvent(EventName.WardrobeClearSelFashion));
            }
            return;
        }// end function

        private function updateFashionInfo(param1:Array) : void
        {
            var _loc_7:int = 0;
            var _loc_2:* = Math.ceil(param1.length / 9);
            this._pageSelecter.maxPage = _loc_2;
            var _loc_3:* = (this._pageSelecter.currentPage - 1) * 9;
            var _loc_4:* = this._pageSelecter.currentPage * 9;
            var _loc_5:* = param1.slice(_loc_3, _loc_4);
            if (_loc_5.length < 9)
            {
                _loc_7 = _loc_5.length;
                while (_loc_7 < 9)
                {
                    
                    _loc_5.push({});
                    _loc_7++;
                }
            }
            var _loc_6:* = new DataProvider();
            _loc_6.addItems(_loc_5);
            this._fashionInfoList.dataProvider = _loc_6;
            this._fashionInfoList.drawNow();
            return;
        }// end function

        private function onPageChange(event:Event) : void
        {
            var _loc_2:* = Cache.instance.wardrobe.getFashionsByType(WardrobeWin.currSelWardrobe, WardrobeWin.currSelWardrobe);
            this.updateFashionInfo(_loc_2);
            return;
        }// end function

        private function onChangeShapeHandler(event:MouseEvent) : void
        {
            if (WardrobeWin.currSelFashionData == null)
            {
                MsgManager.showRollTipsMsg(Language.getString(41403));
                return;
            }
            switch(WardrobeWin.currSelWardrobe)
            {
                case EAdvanceComponentType._EAdvanceComponentTypeClothes:
                case EAdvanceComponentType._EAdvanceComponentTypeWing:
                case EAdvanceComponentType._EAdvanceComponentTypeWeapon:
                {
                    GameProxy.fashion.changeShape(WardrobeWin.currSelFashionData.itemCode, WardrobeWin.currSelWardrobe);
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypePet:
                {
                    GameProxy.pet.changeSharp(WardrobeWin.currSelFashionData.itemCode);
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypeMount:
                {
                    GameProxy.mount.mountIllusion(WardrobeWin.currSelFashionData.itemCode);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function onCancelChangeHandler(event:MouseEvent) : void
        {
            if (WardrobeWin.currSelFashionData == null)
            {
                return;
            }
            switch(WardrobeWin.currSelWardrobe)
            {
                case EAdvanceComponentType._EAdvanceComponentTypeClothes:
                case EAdvanceComponentType._EAdvanceComponentTypeWing:
                case EAdvanceComponentType._EAdvanceComponentTypeWeapon:
                {
                    GameProxy.fashion.changeShape(0, WardrobeWin.currSelWardrobe);
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypePet:
                {
                    GameProxy.pet.changeSharp(0);
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypeMount:
                {
                    GameProxy.mount.mountIllusion(0);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function onSelFashionShowShape(event:DataEvent) : void
        {
            this._isInitModel = false;
            var _loc_2:* = WardrobeWin.currSelFashionData;
            if (_loc_2)
            {
                this.addModel();
            }
            var _loc_3:* = WardrobeUtil.getShapCodeByType(WardrobeWin.currSelWardrobe);
            this.updateBtnState(_loc_3);
            return;
        }// end function

        private function updateBtnState(param1:int) : void
        {
            var _loc_2:* = WardrobeWin.currSelFashionData;
            if (_loc_2 && _loc_2.itemCode == param1)
            {
            }
            return;
        }// end function

        private function onBgLoadCompl() : void
        {
            if (isDisposed)
            {
                return;
            }
            this.init3DRect();
            this.add3dBg();
            this.initModel();
            return;
        }// end function

        protected function init3DRect() : void
        {
            var _loc_1:Rectangle = null;
            if (this._rect3d == null)
            {
                this._rect3d = Rect3DManager.instance.registerWindow(true, new Rectangle(148 + 4 - 2, 37 + 2, 323, 500), this);
                Rect3DManager.instance.windowShowHander(null, this);
            }
            if (this._scale9gridImg2d == null)
            {
                _loc_1 = new Rectangle(33, 38, 1, 1);
                this._scale9gridImg2d = new Scale9GridImg2DEx(null, GlobalClass.getBitmapData(ImagesConst.PlayerBg), true, _loc_1);
                this._scale9gridImg2d.SetSize(323 + 2, 500 + 5, -2, -2);
                this._rect3d.addImg(this._scale9gridImg2d, Layer3DManager.backGroudImgLayer);
            }
            return;
        }// end function

        private function add3dBg() : void
        {
            if (this._rect3d)
            {
                if (this._img2d)
                {
                    this._rect3d.removeImg(this._img2d);
                }
                this._img2d = new Img2D(null, this._bg.bitmapData, new Rectangle(0, 0, 323, 500), false);
                this._rect3d.addImg(this._img2d);
            }
            return;
        }// end function

        private function initModel() : void
        {
            this._isInitModel = true;
            this.addModel();
            return;
        }// end function

        private function addModel() : void
        {
            this.removeModel();
            switch(WardrobeWin.currSelWardrobe)
            {
                case EAdvanceComponentType._EAdvanceComponentTypeMount:
                {
                    this.addMount();
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypePet:
                {
                    this.addPet();
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypeWeapon:
                {
                    this.addWeapon();
                    break;
                }
                case EAdvanceComponentType._EAdvanceComponentTypeClothes:
                case EAdvanceComponentType._EAdvanceComponentTypeWing:
                {
                    this.addUserModel();
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function addMount() : void
        {
            var _loc_1:int = 0;
            var _loc_2:TModel = null;
            var _loc_3:int = 0;
            var _loc_9:ItemData = null;
            var _loc_10:ItemData = null;
            if (this._isInitModel)
            {
                _loc_3 = WardrobeUtil.getShapCodeByType(WardrobeWin.currSelWardrobe);
                if (_loc_3 > 100)
                {
                    _loc_9 = Cache.instance.wardrobe.getCurrShapEquip(WardrobeWin.currSelWardrobe, _loc_3);
                    _loc_1 = _loc_9 == null ? (0) : ((_loc_9.itemInfo as ItemEquipInfo).modelId);
                }
                else
                {
                    _loc_1 = Cache.instance.mount.mountData.tMountConfig.modelId;
                }
            }
            else
            {
                _loc_10 = WardrobeWin.currSelFashionData;
                if (_loc_10 == null)
                {
                    return;
                }
                _loc_3 = _loc_10.itemCode;
                _loc_1 = (_loc_10.itemInfo as ItemEquipInfo).modelId;
            }
            _loc_2 = ModelConfig.instance.getInfoByCode(_loc_1);
            if (_loc_2 == null)
            {
                return;
            }
            var _loc_4:* = _loc_2.mesh1 + ".md5mesh";
            var _loc_5:* = _loc_2.texture1;
            var _loc_6:* = _loc_2.bone1 + ".skeleton";
            if (this._bodyPlayer)
            {
                this._rect3d.disposeObj3d(this._bodyPlayer);
            }
            this._bodyPlayer = FrObjectPool.getObject(ActionPlayer, this);
            this._bodyPlayer.changeAction(ActionName.MountStand);
            this._bodyPlayer.selectEnabled = false;
            this._bodyPlayer.play();
            this._bodyPlayer.scaleValue = _loc_3 > 100 ? (0.7) : (1.3);
            this._bodyPlayer.setRotation(0, 45, 0);
            this._bodyPlayer.load(_loc_4, _loc_6, _loc_5, this._rect3d.renderList);
            this._rect3d.addObject3d(this._bodyPlayer, 180 - 40 + 15, 260 + 53 + 40);
            this._rotate3d.model = this._bodyPlayer;
            var _loc_7:* = VipConfig.instance.isShowEffect(EVipRecordType._EVipRecordTypeMountEffect, Cache.instance.vip.level);
            if (_loc_3 < 100 && !_loc_7)
            {
                return;
            }
            var _loc_8:* = Cache.instance.mount.mountData;
            if (this._rect3d && _loc_8)
            {
                if (this._mountHangEffect)
                {
                    this._rect3d.disposeObj3d(this._mountHangEffect);
                    this._mountHangEffect = null;
                }
                if (_loc_2.effect1)
                {
                    this._mountHangEffect = EffectPlayerPool.instance.getEffectPlayer(_loc_2.effect1, this._bodyPlayer, this._rect3d.renderList, false);
                    if (this._mountHangEffect.temple is TempleRole)
                    {
                        (this._mountHangEffect.temple as TempleRole).setRoleParams(this._bodyPlayer, null, null);
                    }
                    this._mountHangEffect.play(PlayMode.ANIMATION_LOOP_MODE);
                }
            }
            return;
        }// end function

        private function addPet() : void
        {
            var _loc_1:int = 0;
            var _loc_2:TModel = null;
            var _loc_3:int = 0;
            var _loc_4:ItemData = null;
            var _loc_5:ItemData = null;
            var _loc_6:EntityModelInfo = null;
            var _loc_7:TModel = null;
            var _loc_8:String = null;
            var _loc_9:String = null;
            if (this._isInitModel)
            {
                _loc_3 = WardrobeUtil.getShapCodeByType(WardrobeWin.currSelWardrobe);
                if (_loc_3 > 100)
                {
                    _loc_4 = Cache.instance.wardrobe.getCurrShapEquip(WardrobeWin.currSelWardrobe, _loc_3);
                    _loc_1 = _loc_4 == null ? (0) : ((_loc_4.itemInfo as ItemEquipInfo).modelId);
                }
                else
                {
                    _loc_1 = Cache.instance.newPet.petConfig.modelId;
                }
            }
            else
            {
                _loc_5 = WardrobeWin.currSelFashionData;
                if (_loc_5 == null)
                {
                    return;
                }
                _loc_3 = _loc_5.itemCode;
                _loc_1 = (_loc_5.itemInfo as ItemEquipInfo).modelId;
            }
            if (this._rect3d)
            {
                _loc_6 = PetUtil.getPetModel(1, _loc_1);
                _loc_7 = ModelConfig.instance.getInfoByCode(_loc_1);
                _loc_8 = _loc_6.mesh + ".md5mesh";
                _loc_9 = _loc_6.bone + ".skeleton";
                if (this._bodyPlayer)
                {
                    this._rect3d.disposeObj3d(this._bodyPlayer);
                }
                this._bodyPlayer = FrObjectPool.getObject(ActionPlayer, this);
                this._bodyPlayer.changeAction(ActionName.Stand);
                this._bodyPlayer.hangBoneName = BoneConst.MountHangModelBone;
                this._bodyPlayer.selectEnabled = true;
                this._bodyPlayer.play();
                this._bodyPlayer.setRotation(0, 0, 0);
                this._bodyPlayer.scaleValue = PetUtil.petScaleValue(_loc_6.proportion1) * 2;
                this._bodyPlayer.load(_loc_8, _loc_9, _loc_6.texture, this._rect3d.renderList);
                if (_loc_7.sortNum == 1)
                {
                    this._rect3d.addObject3d(this._bodyPlayer, 239 - 79, 327 + 18);
                }
                else
                {
                    this._rect3d.addObject3d(this._bodyPlayer, 239 - 79, 327 + 18);
                }
                this._rotate3d.model = this._bodyPlayer;
                PetSelfEffectUtil.addSelfEffect(this._bodyPlayer, _loc_6.effect, this._rect3d.renderList);
            }
            return;
        }// end function

        private function addUserModel() : void
        {
            var _loc_1:int = 0;
            var _loc_2:TModel = null;
            var _loc_3:int = 0;
            var _loc_4:ItemData = null;
            var _loc_5:FashionAdvanceData = null;
            var _loc_6:ItemData = null;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_9:int = 0;
            var _loc_10:int = 0;
            var _loc_11:int = 0;
            var _loc_12:int = 0;
            var _loc_13:int = 0;
            if (this._isInitModel)
            {
                _loc_3 = WardrobeUtil.getShapCodeByType(WardrobeWin.currSelWardrobe);
                if (_loc_3 > 100)
                {
                    _loc_4 = Cache.instance.wardrobe.getCurrShapEquip(WardrobeWin.currSelWardrobe, _loc_3);
                    _loc_1 = _loc_4 == null ? (0) : ((_loc_4.itemInfo as ItemEquipInfo).modelId);
                }
                else
                {
                    _loc_5 = Cache.instance.fashion.getFashionInfo(WardrobeWin.currSelWardrobe);
                    _loc_1 = _loc_5.baseInfo ? (_loc_5.baseInfo.modelId) : (0);
                }
            }
            else
            {
                _loc_6 = WardrobeWin.currSelFashionData;
                if (_loc_6 == null)
                {
                    return;
                }
                _loc_3 = _loc_6.itemCode;
                _loc_1 = (_loc_6.itemInfo as ItemEquipInfo).modelId;
            }
            if (this._rect3d)
            {
                this._roleModelPlayer = FrObjectPool.getObject(UserModelPlayer, this);
                _loc_7 = Cache.instance.role.entityInfo.career;
                _loc_8 = Cache.instance.role.entityInfo.sex;
                _loc_9 = Cache.instance.role.roleEntityInfo.clothes;
                _loc_10 = Cache.instance.role.roleEntityInfo.weapon;
                _loc_11 = Cache.instance.role.roleEntityInfo.hair;
                _loc_12 = Cache.instance.role.roleEntityInfo.wing;
                _loc_13 = Cache.instance.role.roleEntityInfo.entityInfo.VIP;
                if (_loc_3 > 100)
                {
                    this._roleModelPlayer.updateIsShowEffect(true, true, true);
                }
                if (WardrobeWin.currSelWardrobe == EAdvanceComponentType._EAdvanceComponentTypeClothes)
                {
                    this._roleModelPlayer.updateInfo(_loc_7, _loc_8, _loc_9, 0, 0, 0, _loc_13);
                }
                else
                {
                    this._roleModelPlayer.updateInfo(_loc_7, _loc_8, _loc_9, 0, 0, _loc_12, _loc_13);
                }
                this._roleModelPlayer.scaleAll = 2.3;
                this._roleModelPlayer.useLight();
                this._roleModelPlayer.setRotation(0, 0, 0);
                this._rect3d.addObject3d(this._roleModelPlayer, 73 + 94, 133 + 223 + 18);
                this._rotate3d.model = this._roleModelPlayer;
                if (WardrobeWin.currSelWardrobe == EAdvanceComponentType._EAdvanceComponentTypeClothes)
                {
                    this._roleModelPlayer.clothes = _loc_1;
                    this._roleModelPlayer.loadClothes();
                }
                else
                {
                    this._roleModelPlayer.wing = _loc_1;
                    this._roleModelPlayer.loadWing();
                }
            }
            return;
        }// end function

        private function addWeapon() : void
        {
            var _loc_1:int = 0;
            var _loc_2:TModel = null;
            var _loc_3:int = 0;
            var _loc_4:ItemData = null;
            var _loc_5:FashionAdvanceData = null;
            var _loc_6:ItemData = null;
            var _loc_7:UserModelPlayer = null;
            var _loc_8:int = 0;
            var _loc_9:int = 0;
            var _loc_10:int = 0;
            var _loc_11:int = 0;
            var _loc_12:int = 0;
            var _loc_13:int = 0;
            var _loc_14:int = 0;
            var _loc_15:TPlayerModel = null;
            var _loc_16:int = 0;
            var _loc_17:int = 0;
            if (this._isInitModel)
            {
                _loc_3 = WardrobeUtil.getShapCodeByType(WardrobeWin.currSelWardrobe);
                if (_loc_3 > 100)
                {
                    _loc_4 = Cache.instance.wardrobe.getCurrShapEquip(WardrobeWin.currSelWardrobe, _loc_3);
                    _loc_1 = _loc_4 == null ? (0) : ((_loc_4.itemInfo as ItemEquipInfo).modelId);
                }
                else
                {
                    _loc_5 = Cache.instance.fashion.getFashionInfo(WardrobeWin.currSelWardrobe);
                    _loc_1 = _loc_5.baseInfo ? (_loc_5.baseInfo.modelId) : (0);
                }
            }
            else
            {
                _loc_6 = WardrobeWin.currSelFashionData;
                if (_loc_6 == null)
                {
                    return;
                }
                _loc_3 = _loc_6.itemCode;
                _loc_1 = (_loc_6.itemInfo as ItemEquipInfo).modelId;
            }
            if (this._rect3d)
            {
                _loc_7 = FrObjectPool.getObject(UserModelPlayer, this);
                _loc_8 = Cache.instance.role.entityInfo.career;
                _loc_9 = Cache.instance.role.entityInfo.sex;
                _loc_10 = Cache.instance.role.roleEntityInfo.clothes;
                _loc_11 = Cache.instance.role.roleEntityInfo.weapon;
                _loc_12 = Cache.instance.role.roleEntityInfo.hair;
                _loc_13 = Cache.instance.role.roleEntityInfo.wing;
                _loc_14 = Cache.instance.role.roleEntityInfo.entityInfo.VIP;
                _loc_7.updateInfo(_loc_8, _loc_9, _loc_10, _loc_11, _loc_12, _loc_13, _loc_14);
                _loc_15 = _loc_7.getModelInfo(ModelType.WEAPONS, _loc_1);
                if (_loc_15 == null)
                {
                    return;
                }
                this._weaponPlayer = FrObjectPool.getObject(WeaponPlayer, this);
                this._weaponPlayer.enabledPool = false;
                this._weaponPlayer.scaleX = 1.5;
                this._weaponPlayer.scaleY = 1.5;
                this._weaponPlayer.scaleZ = 1.5;
                this._weaponPlayer.rotationZ = -20;
                switch(_loc_8)
                {
                    case ECareer._ECareerWarrior:
                    {
                        _loc_16 = 180 - 40;
                        _loc_17 = 245 + 52;
                        break;
                    }
                    case ECareer._ECareerArcher:
                    {
                        _loc_16 = 180 - 40;
                        _loc_17 = 165 + 52;
                        break;
                    }
                    case ECareer._ECareerMage:
                    {
                        _loc_16 = 180 - 40;
                        _loc_17 = 185 + 52;
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
                this._rect3d.addObject3d(this._weaponPlayer, _loc_16, _loc_17);
                this._weaponPlayer.load(_loc_15.mesh + ".md5mesh", _loc_15.texture, this._rect3d.renderList);
                this.stopTurn();
                if (this._frameTimer == null)
                {
                    this._frameTimer = new FrameTimer();
                    this._frameTimer.addListener(TimerType.ENTERFRAME, this.onTimerFrameHandler);
                }
                this._frameTimer.start();
                this.removeWeaponEffect();
                if (_loc_15 && _loc_15.selfEffect)
                {
                    this._weaponEffectPlayer = EffectPlayerPool.instance.getEffectPlayer(_loc_15.selfEffect, this._weaponPlayer, this._rect3d.renderList, true);
                    if (this._weaponEffectPlayer.temple is TempleRole)
                    {
                        (this._weaponEffectPlayer.temple as TempleRole).setRoleParams(this._weaponPlayer, null, null);
                    }
                    this._weaponEffectPlayer.play();
                }
            }
            return;
        }// end function

        private function onTimerFrameHandler(param1:FrameTimer) : void
        {
            this.modelTurn();
            return;
        }// end function

        private function stopTurn() : void
        {
            if (this._frameTimer)
            {
                this._frameTimer.stop();
            }
            this._turnNum = 0;
            return;
        }// end function

        private function modelTurn() : void
        {
            var _loc_1:* = this._turnNum + 0.1;
            this._turnNum = this._turnNum + 0.1;
            this._weaponPlayer.y = this._weaponPlayer.y + Math.cos(_loc_1) * 1;
            this._weaponPlayer.rotationY = this._weaponPlayer.rotationY + 5;
            return;
        }// end function

        private function removeWeaponEffect() : void
        {
            if (this._weaponEffectPlayer)
            {
                this._weaponEffectPlayer.dispose();
                this._weaponEffectPlayer = null;
            }
            return;
        }// end function

        private function removeModel() : void
        {
            if (this._bodyPlayer)
            {
                this._rect3d.disposeObj3d(this._bodyPlayer);
                this._bodyPlayer = null;
            }
            if (this._roleModelPlayer)
            {
                this._rect3d.disposeObj3d(this._roleModelPlayer);
                this._roleModelPlayer = null;
            }
            if (this._mountHangEffect)
            {
                this._rect3d.disposeObj3d(this._mountHangEffect);
                this._mountHangEffect = null;
            }
            this.stopTurn();
            if (this._weaponPlayer)
            {
                this._rect3d.disposeObj3d(this._weaponPlayer);
                this._weaponPlayer = null;
            }
            if (this._weaponEffectPlayer)
            {
                this._rect3d.disposeObj3d(this._weaponEffectPlayer);
                this._weaponEffectPlayer = null;
            }
            return;
        }// end function

        private function clear3D() : void
        {
            if (this._rect3d)
            {
                if (this._img2d)
                {
                    this._rect3d.removeImg(this._img2d);
                    this._img2d = null;
                }
                this.removeModel();
            }
            return;
        }// end function

        private function remove3D() : void
        {
            this.clear3D();
            if (this._rect3d)
            {
                if (this._scale9gridImg2d)
                {
                    this._rect3d.disposeObj3d(this._scale9gridImg2d);
                    this._scale9gridImg2d = null;
                }
                Rect3DManager.instance.disposeRect3d(this._rect3d);
                this._rect3d = null;
            }
            return;
        }// end function

        private function clear() : void
        {
            WardrobeWin.currSelFashionData = null;
            return;
        }// end function

        private function onFashionEquipUpdate(param1:Object) : void
        {
            var _loc_3:Array = null;
            var _loc_2:* = param1 as int;
            if (WardrobeWin.currSelWardrobe == _loc_2)
            {
                _loc_3 = Cache.instance.wardrobe.getFashionsByType(WardrobeWin.currSelWardrobe, WardrobeWin.currSelFashionType);
                this.updateFashionInfo(_loc_3);
            }
            return;
        }// end function

        private function onMountEquipUpdate(param1:Object) : void
        {
            var _loc_2:Array = null;
            if (WardrobeWin.currSelWardrobe == EAdvanceComponentType._EAdvanceComponentTypeMount)
            {
                _loc_2 = Cache.instance.wardrobe.getFashionsByType(WardrobeWin.currSelWardrobe, WardrobeWin.currSelFashionType);
                this.updateFashionInfo(_loc_2);
            }
            return;
        }// end function

        private function onPetEquipUpdate(param1:Object) : void
        {
            var _loc_2:Array = null;
            if (WardrobeWin.currSelWardrobe == EAdvanceComponentType._EAdvanceComponentTypePet)
            {
                _loc_2 = Cache.instance.wardrobe.getFashionsByType(WardrobeWin.currSelWardrobe, WardrobeWin.currSelFashionType);
                this.updateFashionInfo(_loc_2);
            }
            return;
        }// end function

        private function onFashionShapChange(param1:Object) : void
        {
            var _loc_2:* = param1 as int;
            this.updateBtnState(_loc_2);
            return;
        }// end function

        private function onPetShapChange(param1:Object) : void
        {
            var _loc_2:* = Cache.instance.newPet.getShowCode;
            this.updateBtnState(_loc_2);
            return;
        }// end function

        private function onMountShapChange(param1:Object) : void
        {
            var _loc_2:* = Cache.instance.mount.mountData.sPublicMount.sharpId;
            this.updateBtnState(_loc_2);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._bg.dispose();
            this._bg = null;
            this._categoryList.dispose();
            this._categoryList = null;
            this._fashionInfoList.dispose();
            this._fashionInfoList = null;
            this._pageSelecter.dispose();
            this._pageSelecter = null;
            this._boxIsActive.dispose();
            this._boxIsActive = null;
            this._boxForever.dispose();
            this._boxForever = null;
            this._boxTimeLimit.dispose();
            this._boxTimeLimit = null;
            this._boxExpired.dispose();
            this._boxExpired = null;
            this._rotate3d.dispose();
            this._rotate3d = null;
            this._equipArr.length = 0;
            this._isInitModel = false;
            this.remove3D();
            this.removeListeners();
            return;
        }// end function

        public static function get instance() : WardrobeWin
        {
            if (_instance == null)
            {
                _instance = new WardrobeWin;
            }
            return _instance;
        }// end function

        public static function get isViewShow() : Boolean
        {
            return _instance && !_instance.isHide;
        }// end function

    }
}
